#pragma once
#ifndef SYNC_TIME_H
#define SYNC_TIME_H

#include <cstdio>
#include <string>
#include "esp_sntp.h"

#ifdef __cplusplus

extern "C"
{
    class SntpTime
    {
    private:
        struct tm time_info;

        SntpTime() {}

    public:
        typedef enum
        {
            YEAR,
            MONTH,
            DAY,
            HOUR,
            MINUTE,
            SECOND,
            WEEKDAY,
        } time_type_t;

        void init();
        struct tm *asStruct(std::string time_zone_value = "CST-8");
        std::string asString(std::string time_zone_value = "CST-8");
        uint32_t asTimestamp(std::string time_zone_value);

        static SntpTime &GetInstance()
        {
            static SntpTime instance;
            return instance;
        }
        // 删除拷贝构造函数和赋值运算符
        SntpTime(const SntpTime &) = delete;
        SntpTime &operator=(const SntpTime &) = delete;
    };
}
#endif

#endif